<?php

namespace app\services;

use app\services\base\BaseService;
use yii\helpers\ArrayHelper;

/**
 * Class User
 * @package app\services
 */
class User
{
    use BaseService;

    /**
     * Check referrer correct
     *
     * @param $user_id
     * @param $referrer_id
     * @return bool
     */
    public static function checkReferrer($user_id, $referrer_id)
    {
        $children = Chain::getChildrenAll($user_id);
        $children = ArrayHelper::getColumn($children, 'id');

        if (in_array($referrer_id, array_merge($children, [$user_id]))) {
            return true;
        }

        return false;
    }
}